package com.yulongtian.oneProblemEveryDay.month202211.day20221129;

import java.util.Arrays;

/**
 * https://leetcode.cn/problems/largest-local-values-in-a-matrix/
 * 可
 *
 * @author yulongTian
 * @create 2022-11-29 10:22
 */
public class Test03 {
    public static void main(String[] args) {
        int[][] grid = {{9, 9, 8, 1}, {5, 6, 2, 6}, {8, 2, 6, 4}, {6, 2, 2, 2}};
        int[][] ints = largestLocal(grid);
        System.out.println(Arrays.deepToString(ints));


    }

    public static int[][] largestLocal(int[][] grid) {

        int len = grid.length;
        int[][] res = new int[len - 2][len - 2];

        for (int i = 1; i < len - 1; i++) {
            for (int j = 1; j < len - 1; j++) {
                int temp = 0;
                for (int p = 0; p < 3; p++) {
                    for (int q = 0; q < 3; q++) {
                        temp = Math.max(temp, grid[i - 1 + p][j - 1 + q]);
                    }
                }
                res[i - 1][j - 1] = temp;
            }
        }
        return res;
    }

}
